home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Carousel
/
CAROUSEL.cdr
/
mactosh
/
utilprn
/
hpdeskje.sit
/
HPDJet ƒ
/
save_last_used.c
< prev
next >
Wrap
Text File
|
1989-04-02
|
2KB
|
61 lines
/* 02.04.1989 amn (latest edit) */
/* save_last_used.c - printer driver for Macintosh and HP DeskJet, code fragment */
/* to save last used print record. */
/* Authors: Ari Mujunen (amn@hutcs.hut.fi) and Olli Arnberg (oar@hutcs.hut.fi). */
/* Copyright Ari Mujunen, Olli Arnberg 1989. */
/* You may redistribute the driver (=printer resource file, source files, */
/* documentation file(s), and the file 'Copyright and Source Offer') */
/* only _non-commercially_ and _in its entirety_. */
/* See the file 'Copyright and Source Offer' and/or documentation for details. */
/* Acknowledgements: Special thanks to Mr. Earle R. Horton for his 'Daisy' */
/* daisywheel printer driver and its source code published in 'MacTutor', Nov-Dec 1987. */
/* This driver served as a basis and inspiration for our work. It also */
/* proofed that a Macintosh printer driver can be done despite the lack of */
/* documentation from Apple. */
/* Change history: */
/* Version When Who Why */
/* 2.1 02.04.1989 amn,oar Released version. */
{ /* Save last used print record into printer driver resource file. */
THPrint savePrint;
int saveResFileRefNum;
saveResFileRefNum = CurResFile();
UseResFile(
HomeResFile(
GetResource('PDEF', NUMBER_OF_THIS_PDEF)
)
);
savePrint = (THPrint)GetResource('PREC', 1);
if (savePrint != nil) { /* PREC exists, change it */
LoadResource(savePrint);
HNoPurge(savePrint);
**savePrint = **hPrint;
ChangedResource(savePrint);
/* if (ResError()...; but there is not much we can do */
WriteResource(savePrint);
HPurge(savePrint);
}
else { /* PREC doesn't exist, create it */
savePrint = (THPrint)NewHandle((long)(sizeof(TPrint)));
/* This should be allocated from system heap if MF is running. ??? */
if (savePrint != nil) {
**savePrint = **hPrint;
AddResource(savePrint, 'PREC', 1, "\pLast used");
if (ResError() == noErr) {
WriteResource(savePrint);
HPurge(savePrint);
}
else {
DisposHandle(savePrint);
} /* if resource added */
} /* if memory allocated */
} /* else create new PREC */
UseResFile(saveResFileRefNum);
} /* end save 'PREC' 1 */